package com.yixun.qfbao.hander;

import com.alibaba.fastjson.JSONObject;
import com.yixun.qfbao.api.service.ReportCommissionInfoService;
import com.yixun.qfbao.apidto.DealReportCommissionReqDto;
import com.yixun.qfbao.apidto.DealReportCommissionResDto;
import com.yixun.qfbao.apidto.GetReportCommissionLogResDto;
import com.yixun.qfbao.apidto.ReportCommissionLogReqDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.DealReportCommissionReqVo;
import com.yixun.qfbao.vo.GetReportCommissionLogListReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: channel-parent
 *
 * @description: 获取报备佣金修改历史信息
 *
 * @author: Seven.wang
 *
 * @create: 2020-07-06 18:22
 **/
@Service("getReportCommissionLogListHander")
public class GetReportCommissionLogListHander extends CommonAbstractHander {

    private static Logger logger= LoggerFactory.getLogger(GetReportCommissionLogListHander.class);

    @Autowired
    private ReportCommissionInfoService reportCommissionInfoService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetReportCommissionLogListReqVo reqVo = (GetReportCommissionLogListReqVo)reqDto;
        GetReportCommissionLogResDto resDto = new GetReportCommissionLogResDto();
        ReportCommissionLogReqDto reqDto1 = reqVo.getParams();
        BaseResponseDTO<GetReportCommissionLogResDto> res = new BaseResponseDTO<GetReportCommissionLogResDto>();
        logger.info("GetReportCommissionLogListHander ReportCommissionLogReqDto info : {}", JSONObject.toJSONString(reqDto1));
        try {
            resDto = reportCommissionInfoService.getReportCommissionLogList(reqDto1);
        }catch (Exception e){
            logger.error("GetReportCommissionLogListHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("系统异常");
        }

        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
